<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); 
/**
*
* @version $Id: account.index.tpl.php 1443 2008-06-30 18:39:22Z soeren_nb $
* @package VirtueMart
* @subpackage html
* @copyright Copyright (C) 2004-2008 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/

require_once ( CLASSPATH. 'ps_user.php');

$ps_user = new ps_user;
if ($perm->is_registered_customer($auth['user_id']) ) {
if($auth['perms']=="storeadmin") { 
    $vendor_id = $ps_user->getUserInfomations($auth['user_id'])->record[0]->vendor_id;
    require_once ( CLASSPATH . "ps_search_pos.php" );
    $arrVendors = ps_search_pos::getRestaurantList($vendor_id, '', '');
?>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php echo $GLOBALS['MAP_GOOGLE_KEY']; ?>" type="text/javascript"></script>
<script src="libraries/googlemap/js/GoogleFuncs.js" type="text/javascript"></script>
<table width="100%">
  <tr>
    <td width="50%"> <span style="font-size: 20px;"><?php  echo $auth["first_name"] . " " . $auth["last_name"];?></span></td>
    <td>
        <table width="100%">
        <tr>
            <td>
                 <a style="font-weight: bold;" href="<?php $sess->purl(SECUREURL . "index.php?option=com_virtuemart&page=shop.browse&vendor_id=".$vendor_id."&Itemid=11") ?>">
                 Menu
                </a>
            </td>
            <td width="10px" align="center">||</td>
            <td align="center">
                <a style="font-weight: bold;" href="<?php $sess->purl(SECUREURL . "index.php?option=com_virtuemart&page=shop.registration_restaurant&vendor_id=".$vendor_id."&Itemid=15") ?>">
                <?php echo $VM_LANG->_('PHPSHOP_ACC_ACCOUNT_INFO') ?>
                </a>
            </td>
            <td width="10px" align="center">||</td>
            <td align="center">
                <a style="font-weight: bold;" href="<?php $sess->purl(SECUREURL . "index.php?option=com_virtuemart&page=account.order_list&vendor_id=".$vendor_id."&Itemid=15") ?>">
                <?php echo $VM_LANG->_('PHPSHOP_ACC_ORDER_INFO') ?>
                </a>
            </td>
        </tr>
        </table>
    </td>
  </tr>  
  <tr>
    <td valign="top">
        <div>
            <table cellpadding="0" cellspacing="0" border="0" width="98%" style="color: #000;">
                <tr style="font-weight: bold;">
                    <td width="5%"></td>
                    <td width="40%" align="left"><?php echo $VM_LANG->_('PHPSHOP_SEARCH_POS_RESTAURANT') ?></td>
                    <td width="20%" align="left"><?php echo $VM_LANG->_('PHPSHOP_SEARCH_POS_KEYWORD') ?></td>
                    <td width="20%" align="left"><?php echo $VM_LANG->_('PHPSHOP_SEARCH_POS_DELIVERY') ?></td>
                    <td width="15%" align="left"><?php echo $VM_LANG->_('PHPSHOP_SEARCH_POS_FAVORITE') ?></td>
                </tr>
                <?php 
                $bg = "background-color: #CCCCCC;";
                for ($n = 0; $n < count($arrVendors['vendors']); $n++) {
                    $obj = $arrVendors['vendors'][$n];
                    $bg = ($n%2 == 0) ? $bg : "";
                ?>
                <tr style="<?php echo $bg; ?>">
                    <td align="right"><?php echo ($n + 1); ?>.&nbsp;</td>
                    <td style="color: #CC0000; font-weight: bold;"><a href="<?php echo $sess->purl( $mm_action_url."index.php?option=com_virtuemart&page=shop.browse&vendor_id=".$obj['vendor_id']); ?>" style="color: #CC0000;"><?php echo $obj['vendor_name']; ?></a></td>
                    <td align="center"><?php echo $obj['vendor_keyword']; ?></td>
                    <td align="center"><?php echo $obj['vendor_delivery']; ?></td>
                    <td align="center"></td>
                </tr>
                 <tr style="<?php echo $bg; ?>">
                             <td></td>
                             <td colspan="4">
                             <?php 
                                echo $obj['vendor_address_1']; 
                                if($obj['vendor_address_2']!='')
                                    echo ', '.$obj['vendor_address_2'];
                                if($obj['vendor_city']!='')
                                    echo ', '.$obj['vendor_city'];
                                if($obj['vendor_state']!='')
                                    echo ', '.$obj['vendor_state'];
                                if($obj['vendor_zip']!='')
                                    echo ', '.$obj['vendor_zip'];
                                if($obj['vendor_phone']!='')
                                    echo ', '.$obj['vendor_phone'];  
                             ?>                    
                             </td>
                             </tr>
                <tr style="<?php echo $bg; ?>">
                    <td></td>
                    <td colspan="4"><?php echo $VM_LANG->_('PHPSHOP_SEARCH_POS_CUISINE') ?>: <?php echo $obj['vendor_cuisine']; ?></td>
                </tr>
                <tr style="<?php $bg; ?>">
                    <td align="right"></td>
                    <td colspan="4">
                        <?php //echo $VM_LANG->_('PHPSHOP_SEARCH_POS_VIEW_DAILY_SPEC') ?>
                        <?php
                            require_once( CLASSPATH . 'ps_product_category.php' );   
                            $category_id= ps_product_category::getCategoryId($obj['vendor_id']);   
                            
                            include( "modules/mod_virtuemart_featureprod/mod_virtuemart_featureprod.php" );
                        ?>
                    </td>                    
                </tr>
                <?php } ?>
                 <tr>
                    <td colspan="2">
                         <br/>
                    </td>                    
                </tr>
                <tr>
                    <td colspan="2">
                        <span style="font-size: 14px;font-weight: bold;">Marketing Login</span>
                    </td>                    
                </tr>
                <tr>
                    <td colspan="2">
                        Email Address:
                    </td>                    
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="text" />
                    </td>                    
                </tr>
                <tr>
                    <td colspan="2">
                        Password
                    </td>                    
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="text" />
                    </td>                    
                </tr>
                <tr>
                    <td colspan="2">
                    <br/>
                        <input type="button" value="Enter" style="width: 185px;height: 30px;" />
                    </td>                    
                </tr>
            </table>
        </div>
    </td>
    <td>
        <div id="map" style="width: 370px; height: 300px"></div>
        <table cellpadding="0" cellspacing="0" border="0" width="370px" style="margin-top: 5px; color: #666666;">
            <tr style="background-color: #CCCCCC;">
                <td style="font-weight: bold; width: 80px;">&nbsp;&nbsp;<?php echo $VM_LANG->_('PHPSHOP_SEARCH_POS_RADIUS') ?>:</td>
                <td>
                    <input type="radio" name="miles_group" id="5miles" checked="checked" value="5" onclick="_GoogleMaps_.radiusChanged(5)"/>
                    <label for="5miles">5 miles</label>&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" name="miles_group" id="10miles" value="10" onclick="_GoogleMaps_.radiusChanged(10)"/>
                    <label for="10miles">10 miles</label>&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" name="miles_group" id="15miles" value="15" onclick="_GoogleMaps_.radiusChanged(15)"/>
                    <label for="15miles">15 miles</label>
                </td>
            </tr>
        </table>
    </td>
  </tr>
</table>
<script language="javascript">
<?php echo $arrVendors['address']; ?>

function initSearchPos() {
    var address = '';
    if (_GoogleMaps_.arrAddress[0]) {
        address = _GoogleMaps_.arrAddress[0].address;
    }
    
    var radius = 5;
    
    _GoogleMaps_.init(address, radius);
}
window.onload = initSearchPos;
window.onunload = GUnload;
</script>
<?php }else if($auth['perms']=="shopper"){ ?>
<?php if( $my->id > 0)  { ?> 
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php echo $GLOBALS['MAP_GOOGLE_KEY']; ?>" type="text/javascript"></script>
<script src="libraries/googlemap/js/GoogleFuncs.js" type="text/javascript"></script>
  <strong><?php echo $VM_LANG->_('PHPSHOP_ACC_CUSTOMER_ACCOUNT') ?></strong>
  <?php  echo $auth["first_name"] . " " . $auth["last_name"] . "<br />";?>
  <br />
  <table border="0" cellspacing="0" cellpadding="10" width="100%" align="center"> 
    <tr>
      <td valign="top" width="37%">
      <strong><a href="<?php $sess->purl(SECUREURL . "index.php?page=account.billing&Itemid=10") ?>">
          <?php 
          echo "<img src=\"".VM_THEMEURL."images/identity.png\" align=\"middle\" height=\"48\" width=\"48\" border=\"0\" alt=\"".$VM_LANG->_('PHPSHOP_ACCOUNT_TITLE')."\" />&nbsp;";
          echo $VM_LANG->_('PHPSHOP_ACC_ACCOUNT_INFO') ?></a></strong>
          <br /><?php echo $VM_LANG->_('PHPSHOP_ACC_UPD_BILL') ?>
      </td>
       <?php
    if(NO_SHIPTO != '1') {
    ?> 
          <td valign="top" width="40%">
          <strong><a href="<?php $sess->purl(SECUREURL . "index.php?page=account.shipping") ?>"><?php
                  echo "<img src=\"".VM_THEMEURL."images/web.png\" align=\"middle\" border=\"0\" height=\"32\" width=\"32\" alt=\"".$VM_LANG->_('PHPSHOP_ACC_SHIP_INFO')."\" />&nbsp;&nbsp;&nbsp;";
                  echo $VM_LANG->_('PHPSHOP_ACC_SHIP_INFO') ?></a></strong>
                        <br />
                        <?php echo $VM_LANG->_('PHPSHOP_ACC_UPD_SHIP') ?>
                  </td>                 
   <?php } ?>
    <td valign="top" width="23%">
          
          <strong>
        <!--<a href="<?php //$sess->purl(SECUREURL . "index.php?page=account.orders&Itemid=14") ?>">-->
        <a href="index.php?page=account.orders&option=com_virtuemart&Itemid=14">
        <?php 
          echo "<img src=\"".VM_THEMEURL."images/package.png\" align=\"middle\" height=\"32\" width=\"32\" border=\"0\" alt=\"".$VM_LANG->_('PHPSHOP_ACC_ORDER_INFO')."\" />&nbsp;&nbsp;&nbsp;";
          echo $VM_LANG->_('PHPSHOP_ACC_ORDER_INFO') ?>
        </a>
        </strong>
      </td>
    </tr>    
    <tr>
        <td valign="top" colspan="3">
        <hr>
        <?php 
        $user_id = $auth['user_id'];
        $vendor_ids = ps_order::get_vendor_string($user_id);
        require_once ( CLASSPATH . "ps_search_pos.php" );
        $arrVendors = ps_search_pos::getRestaurantList($vendor_ids, '', '');        
        ?>
        <table cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td width="50%" valign="top">
                    <div>
                        <table cellpadding="0" cellspacing="0" border="0" width="98%" style="color: #000;">
                            <tr style="font-weight: bold;">
                                <td width="5%"></td>
                                <td width="40%" align="left"><?php echo $VM_LANG->_('PHPSHOP_SEARCH_POS_RESTAURANT') ?></td>
                                <td width="20%" align="left"><?php echo $VM_LANG->_('PHPSHOP_SEARCH_POS_KEYWORD') ?></td>
                                <td width="20%" align="left"><?php echo $VM_LANG->_('PHPSHOP_SEARCH_POS_DELIVERY') ?></td>
                                <td width="15%" align="left"><?php echo $VM_LANG->_('PHPSHOP_SEARCH_POS_FAVORITE') ?></td>
                            </tr>
                            <?php 
                            $bg = "background-color: #CCCCCC;";
                            for ($n = 0; $n < count($arrVendors['vendors']); $n++) {
                                $obj = $arrVendors['vendors'][$n];
                                $bg = ($n%2 == 0) ? $bg : "";
                            ?>
                            <tr style="<?php echo $bg; ?>">
                                <td align="right"><?php echo ($n + 1); ?>.&nbsp;</td>
                                <td style="color: #CC0000; font-weight: bold;"><a href="<?php echo $sess->purl( $mm_action_url."index.php?option=com_virtuemart&page=shop.browse&vendor_id=".$obj['vendor_id']); ?>" style="color: #CC0000;"><?php echo $obj['vendor_name']; ?></a></td>
                                <td align="center"><?php echo $obj['vendor_keyword']; ?></td>
                                <td align="center"><?php echo $obj['vendor_delivery']; ?></td>
                                <td align="center"></td>
                            </tr>
                             <tr style="<?php echo $bg; ?>">
                             <td></td>
                             <td colspan="4">
                             <?php 
                                echo $obj['vendor_address_1']; 
                                if($obj['vendor_address_2']!='')
                                    echo ', '.$obj['vendor_address_2'];
                                if($obj['vendor_city']!='')
                                    echo ', '.$obj['vendor_city'];
                                if($obj['vendor_state']!='')
                                    echo ', '.$obj['vendor_state'];
                                if($obj['vendor_zip']!='')
                                    echo ', '.$obj['vendor_zip'];
                                if($obj['vendor_phone']!='')
                                    echo ', '.$obj['vendor_phone'];  
                             ?>                    
                             </td>
                             </tr>
                            <tr style="<?php echo $bg; ?>">
                                <td></td>
                                <td colspan="4"><?php echo $VM_LANG->_('PHPSHOP_SEARCH_POS_CUISINE') ?>: <?php echo $obj['vendor_cuisine']; ?></td>
                            </tr>
                            <tr style="<?php echo $bg; ?>">
                                <td align="right"></td>
                                <td colspan="4">
                                    <?php //echo $VM_LANG->_('PHPSHOP_SEARCH_POS_VIEW_DAILY_SPEC') ?>
                                    <?php
                                        require_once( CLASSPATH . 'ps_product_category.php' );   
                                        $category_id= ps_product_category::getCategoryId($obj['vendor_id']); 
                                        include( "modules/mod_virtuemart_featureprod/mod_virtuemart_featureprod.php" );
                                    ?>
                                </td>                    
                            </tr>
                            <?php } ?>
                        </table>
                    </div>
                </td>
                <td width="50%">
                    <div id="map" style="width: 370px; height: 300px"></div>
                    <table cellpadding="0" cellspacing="0" border="0" width="370px" style="margin-top: 5px; color: #666666;">
                        <tr style="background-color: #CCCCCC;">
                            <td style="font-weight: bold; width: 80px;">&nbsp;&nbsp;<?php echo $VM_LANG->_('PHPSHOP_SEARCH_POS_RADIUS') ?>:</td>
                            <td>
                                <input type="radio" name="miles_group" id="5miles" checked="checked" value="5" onclick="_GoogleMaps_.radiusChanged(5)"/>
                                <label for="5miles">5 miles</label>&nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="radio" name="miles_group" id="10miles" value="10" onclick="_GoogleMaps_.radiusChanged(10)"/>
                                <label for="10miles">10 miles</label>&nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="radio" name="miles_group" id="15miles" value="15" onclick="_GoogleMaps_.radiusChanged(15)"/>
                                <label for="15miles">15 miles</label>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        </td>
    </tr>
    
</table>
<?php } ?>  
<script language="javascript">
    <?php echo $arrVendors['address']; ?>

    function initSearchPos() {
        var address = '';
        if (_GoogleMaps_.arrAddress[0]) {
            address = _GoogleMaps_.arrAddress[0].address;
        }
        
        var radius = 5;
        
        _GoogleMaps_.init(address, radius);
    }
    window.onload = initSearchPos;
    window.onunload = GUnload;
</script>
<!-- Body ends here -->
<?php }} 
else { 
	// You're not allowed... you need to login.
    echo $VM_LANG->_('DO_LOGIN') .'<br/><br/><br/>';
    include(PAGEPATH.'checkout.login_form.php');
} ?>